package com.example.match.service;

import java.util.Arrays;
import java.util.List;

import com.example.match.model.domain.User;
import jakarta.annotation.Resource;
import org.junit.Assert;
import org.junit.jupiter.api.Test;
import org.springframework.boot.test.context.SpringBootTest;

/*
 * 用户服务测试
 * @author 雨后天晴
 */
@SpringBootTest
class UserServiceTest {

    @Resource
    private UserService userService;

    // @Test
    // public void testAddUser() {
    //     User user = new User();
    //     user.setId(0L);
    //     user.setUsername("sunnyAfterRain");
    //     user.setUserAccount("123");
    //     user.setAvatarUrl("D:\\Users\\17268\\Pictures\\Saved Pictures\640.jpg");
    //     user.setGender(0);
    //     user.setUserPassword("xxx");
    //     user.setPhone("123");
    //     user.setEmail("456");
    //     user.setUserStatus(0);
    //     user.setCreateTime(new Date());
    //     user.setUpdateTime(new Date());
    //     user.setIsDelete(0);
    //     boolean result = userService.save(user);
    //     System.out.println(user.getId());
    //     assertTrue(result);
    // }

    // @Test
    // void userRegister() {
    //     String userAccount = "sunny";
    //     String userPassword = "";
    //     String checkPassword = "123456";
    //     String planetCode = "1";
    //     long result = userService.userRegister(userAccount, userPassword, checkPassword, planetCode);
    //     Assertions.assertEquals(-1, result);
    //     userAccount = "sun";
    //     result = userService.userRegister(userAccount, userPassword, checkPassword, planetCode);
    //     Assertions.assertEquals(-1, result);
    //     userAccount = "sunny";
    //     userPassword = "123456";
    //     result = userService.userRegister(userAccount, userPassword, checkPassword, planetCode);
    //     Assertions.assertEquals(-1, result);
    //     userAccount = "sun ny";
    //     userPassword = "12345678";
    //     result = userService.userRegister(userAccount, userPassword, checkPassword, planetCode);
    //     Assertions.assertEquals(-1, result);
    //     checkPassword = "123456789";
    //     result = userService.userRegister(userAccount, userPassword, checkPassword, planetCode);
    //     Assertions.assertEquals(-1, result);
    //     userAccount = "sunnyAfterRain";
    //     checkPassword = "12345678";
    //     result = userService.userRegister(userAccount, userPassword, checkPassword, planetCode);
    //     Assertions.assertEquals(-1, result);
    //     userAccount = "sunny";
    //     result = userService.userRegister(userAccount, userPassword, checkPassword, planetCode);
    //     Assertions.assertTrue(result > 0);
    // }

    @Test
    void testSearchUsersByTags() {
        List<String> tagNameList = Arrays.asList("java", "c++");
        List<User> userList = userService.searchUserByTags(tagNameList);
        Assert.assertNotNull(userList);
    }
}